package com.tanhua.server.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.tanhua.dubbo.server.api.RecommendUserApi;
import com.tanhua.dubbo.server.pojo.PageInfo;
import com.tanhua.dubbo.server.pojo.RecommendUser;
import com.tanhua.server.vo.TodayBest;
import org.springframework.stereotype.Service;

/**
 * @description: 负责与dubbo服务进行交互
 * @author: Administrator
 * @date: Created in 2021/2/15 14:01
 * @version: 0.0.1
 * @modified By:
 */
@Service
public class RecommendUserService {
    @Reference(version = "1.0.0")
    private RecommendUserApi recommendUserApi;

    public TodayBest queryTodayBest(Long userId) {
        RecommendUser recommendUser = this.recommendUserApi.queryWithMaxScore(userId);
        if(null==recommendUser){
            return null;
        }
        TodayBest todayBest=new TodayBest();
        todayBest.setId(recommendUser.getUserId());
        //缘分值
        double score = Math.floor(recommendUser.getScore());  //取整,98.2->98
        todayBest.setFateValue(Double.valueOf(score).longValue());
        return todayBest;
    }

    public PageInfo<RecommendUser> queryRecommendUserList(Long userId, Integer page, Integer pageSize) {
        return this.recommendUserApi.queryPageInfo(userId,page,pageSize);

    }
    /**
     * @description 查询推荐好友的缘分值
     * @author
     * @date
     * @param
     *@return
     */
    public double queryScore(Long userId, Long id) {
       return this.recommendUserApi.queryScore(userId,id);
    }
}
